package main

import "fmt"

/*
	从指定的字符串中读取数据
	func Sscan(str string, a ...interface{}) (n int, err error)
	func Sscanf(str string, format string, a ...interface{}) (n int, err error)
	func Sscanln(str string, a ...interface{}) (n int, err error) 在换行时，停止；将扫描的文本以空格为分割，返回给参数
*/

func main() {
	str := `
		hello golang +
		he
	`
	res := ""
	res1 := ""

	fmt.Sscan(str, &res, &res1)
	fmt.Println(res, res1) // hello golang

	fmt.Sscanf(str, "$s", &res)
	fmt.Println(res) // hello

	fmt.Sscanln(str, &res, &res1)
	fmt.Println("res=", res)
	fmt.Println("res1:=", res1)
}
